<template lang="pug">
  kalix-dialog.user-add(title='查看' bizKey="message" ref="kalixBizDialog" v-bind:formModel.sync="formModel" isView)
    div.el-form(slot="dialogFormSlot")
      el-input(v-model="formModel.uid" type="hidden")
      <!--el-form-item(label="院系" prop="did" v-bind:label-width="labelWidth")-->
        <!--el-cascader.long(v-model="didCascader" placeholder="请选择院系信息" :options="options" filterable @change="getDep" v-bind:show-all-levels="true" change-on-select disabled)-->
      el-form-item(label="课程" prop="cid" v-bind:label-width="labelWidth")
        el-input(v-model="formModel.cname" style="width:80%" readonly)
      el-form-item(label="评论内容" prop="content" label-width="120px")
        el-input(v-model="formModel.content" style="width:80%" readonly)
      el-form-item(label="评分" prop="score" label-width="120px")
        el-input(v-model="formModel.score" style="width:80%" readonly)
</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import {DepartmentsURL, TrainingVideosUrl} from '../../config.toml'
  export default {
    name: 'messageView',
    data() {
      return {
        formModel: Object.assign({}, FormModel),
        labelWidth: '120px',
        didCascader: [],
        options: []
      }
    },
    mounted() {
      this.getDepCascader() // 获取院系信息并以级联形式显示
    },
    methods: {
      // init(dialogOption) {
      //   console.log('---------dialogOption------------', dialogOption)
      //   this.axios.request({
      //     method: 'GET',
      //     url: DepartmentsURL + '/getEchoByDid', // 通过uri获取级联回显的数据
      //     params: {
      //       did: this.formModel.did
      //     }
      //   }).then(res => {
      //     console.log('res===============', res.data.tag)
      //     this.didCascader = res.data.tag.split(',')
      //     console.log('this.didCascader==========', this.didCascader)
      //   })
      // },
      getDepCascader() { // 获取院系信息并以级联形式显示
        console.log('getDepCascader========================')
        this.axios.request({
          method: 'GET',
          url: DepartmentsURL + '/getDepCascader'
        }).then(res => {
          console.log('getDepCascader==============', res.data.data)
          this.options = res.data.data
        })
      },
      getDep(val) { // 通过级联获取数据后转成字符串
        let ddid = val.toString().substring(val.toString().lastIndexOf(',') + 1, val.toString().length)
        console.log('ddid========================', ddid)
        this.axios.request({
          method: 'GET',
          url: TrainingVideosUrl + '/getDDidBySelect',
          params: {
            did: ddid
          }
        }).then(res => {
          console.log('getDDidBySelect==============', res.data.data)
          this.items = res.data.data
        })
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">

</style>
